﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Puzzler.Plugin.Interface;
using Puzzler.XML;
using Res = Puzzler.GUI.Resources;

namespace Puzzler.GUI.Windows.Wizard
{
    /// <summary>
    /// Interaktionslogik für WizardWindow.xaml
    /// </summary>
    public partial class WizardWindow : Window
    {
        private PuzzleData data;

        internal WizardWindow(PuzzleData data)
        {
            InitializeComponent();
            this.data = data;
        }

        public void PageUpdate()
        {
            PanelInfo info = (pnlPage.SelectedChild as FrameworkElement).Tag as PanelInfo;
            Title = Res.GetString("wizard.title", CultureInfo.CurrentUICulture) + " - " + info.Title;

            pnlPage.RefreshPage();

            btnBack.IsEnabled = pnlPage.HasPrev && info.IsBackEnabled;
            btnNext.IsEnabled = pnlPage.HasNext;
            btnCancel.IsEnabled = info.IsCancelEnabled;
            btnFinish.IsEnabled = info.IsFinishEnabled || pnlPage.IsLastPage;
        }

        public PuzzleData ShowWizard()
        {
            if (ShowDialog().GetValueOrDefault(false))
            {
                return data;
            }

            return null;
        }
    }
}
